const APPID = "efc89f3d";

export function upstream(task, data, status, success) {
  const business = {
    language: "zh_cn",
    domain: "iat",
    accent: "mandarin",
  };

  const upData = {
    status,
    format: "audio/L16;rate=8000",
    encoding: "raw",
    audio: uni.arrayBufferToBase64(data)
  };

  task.send({
    data: JSON.stringify({
      common: {
        app_id: APPID
      },
      business,
      data: upData
    })
  });
  task.onMessage(success);
  task.onError(err => console.log(err))
}